<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>后台管理系统</title>
        <meta name="author" content="BaiYY"/>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <meta name="renderer" content="webkit">
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/bootstrap.min.css"/>
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/Font/css/font-awesome.min.css"/>
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/index.css"/>
        <link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/pages.css"/>
        <script type="text/javascript" src="__PUBLIC__/admin/js/jquery.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/js/bootstrap.min.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/js/index.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/js/time.js"></script>
        <script type="text/javascript" src="__PUBLIC__/admin/js/pages.js"></script>
    </head>
<body>
    <div class="right-sidebar" style="max-width: 1200px">
        <section class="table-responsive">
            <table class="table table-bordered">
                <thead>
                    <tr>
                        <th>游戏ID</th>
                        <th>微信昵称</th>
                        <th>房卡张数</th>
                        <th id="showCoin">{:L(GAME_COUN_NUM)}</th>
                        <th>创建时间</th>
                    </tr>
                </thead>
                <tbody id="dataList"></tbody>
            </table>
        </section>
        <div id="playerPage">
            <a href="javascript:void(0)" id="prev">上一页</a>
            <a href="javascript:void(0)" id="page"></a>
            <a href="javascript:void(0)" id="next">下一页</a>
            <span>一共</span>
            <a href="javascript:void(0)" id="totalPage"></a>
            <span>页</span>
        </div>
    </div>
    <script type="text/javascript">
        $(function () {
            var showCoin = $.trim($("#showCoin").text());
            if(showCoin == '' || showCoin == 'GAME_COUN_NUM') {
                $("#showCoin").hide();
            }
            $.ajax({
                type:"post",
                url:"{:U('Admin/Main/clubMemberList')}",
                success:function (data) {
                    var count = Math.ceil(data.count/10);
                    if(data != 'error') {
                        var str = '';
                        for(var i=0;i<data.arr.length;++i) {
                            if(showCoin == '' || showCoin == null) {
                                str += "<tr><td class='user_id'>"+data.arr[i]._id+"</td><td>"+data.arr[i].info.name+"</td><td>"+data.arr[i].status.card+"</td><td>"+getLocalTime(data.arr[i].info.createTime)+"</td></tr>";
                            }else{
                                str += "<tr><td class='user_id'>"+data.arr[i]._id+"</td><td>"+data.arr[i].info.name+"</td><td>"+data.arr[i].status.card+"</td><td>"+data.arr[i].status.coin+"</td><td>"+getLocalTime(data.arr[i].info.createTime)+"</td></tr>";
                            }
                        }
                        $("#dataList").html(str);
                        $("#page").text(1);
                        $("#totalPage").text(count);
                    }else{
                        $("#dataList").html("暂时没有成员");
                    }
                }
            })
        });
        $("#prev").on("click",function (ev) {
            var page = $.trim($("#page").text());
            if(page == 1) {
                page = 1;
                return false;
            }else if($("#page").text() > 1) {
                page = page - 1;
            }
            var start = $("#dataList tr:first").find("td.user_id").text();
            var action = -1;
            $.ajax({
                type:"post",
                url:"{:U('Admin/Main/clubMemberList')}",
                dataType:"json",
                data:{"start":start,"action":action,"page":page},
                success:function(data) {
                    if(data != 'error') {
                        var str = '';
                        for(var i=0;i<data.arr.length;++i) {
                            str += "<tr><td class='user_id'>"+data.arr[i]._id+"</td><td>"+data.arr[i].info.name+"</td><td>"+data.arr[i].status.card+"</td><td>"+data.arr[i].status.coin+"</td><td>"+getLocalTime(data.arr[i].info.createTime)+"</td></tr>";
                        }
                        $("#dataList").html(str);
                        $("#page").text(page);
                    }
                }
            })
        });

        $("#next").on("click",function (e) {
            var page = $.trim($("#page").text());
            page = ++page;
            var totalPage = $.trim($("#totalPage").text())/1;
            if(page > totalPage) {
                return false;
            }
            var start = $("#dataList tr:last").find("td.user_id").text();
            var action = 1;
            $.ajax({
                type:"post",
                url:"{:U('Admin/Main/clubMemberList')}",
                dataType:"json",
                data:{"start":start,"action":action,"page":page},
                success:function(data) {
                    if(data != 'error') {
                        var str = '';
                        for(var i=0;i<data.arr.length;++i) {
                            str += "<tr><td class='user_id'>"+data.arr[i]._id+"</td><td>"+data.arr[i].info.name+"</td><td>"+data.arr[i].status.card+"</td><td>"+data.arr[i].status.coin+"</td><td>"+getLocalTime(data.arr[i].info.createTime)+"</td></tr>";
                        }
                        $("#dataList").html(str);
                        $("#page").text(page);
                    }
                }
            })
        })
    </script>
</body>
</html>